Skip to content

refactor: simplify composite-action report/format helpers#118

Merged
maxisam merged 1 commit into
mainfrom
refactor/simplify-composite-helpers
Jun 27, 2026
Merged

refactor: simplify composite-action report/format helpers#118
maxisam merged 1 commit into
mainfrom
refactor/simplify-composite-helpers

Conversation

@maxisam

@maxisam maxisam commented Jun 27, 2026

Copy link
Copy Markdown
Owner

Quality cleanups on top of the composite-action migration (#117), from a 4-angle /simplify review (reuse, simplification, efficiency, altitude). No behavior changebiome check + the 33 node:test unit tests pass, the github-script wrappers were smoke-tested, and bash -n + YAML parse are clean.

Changes

  • Reusereport-common.mjs gains buildReportContext(context); both report wrappers (format-report, jscpd-report) call it instead of hand-building the identical owner/repo/sha/cwd/runId/commit object.
  • Reuse/consistencybuildJscpdMessage now takes the pre-computed header (like generateReport) instead of recomputing getReportHeader internally; the wrapper passes it (removes a double call).
  • SimplificationbuildDefaultOptions collapses its 4 near-identical blocks to a base + spread (only the two real overrides remain); checkIsDryRun's granular check uses a small dry() helper ((enabled && verify) || !enabled!enabled || verify); planFormat drops the unused config field from its return; internal-only buildArgs/FormatType are now module-private.
  • EfficiencygetExistingCommentId runs the independent listComments + getAuthenticated calls with Promise.all (the latter still degrades to undefined on a 403).
  • action.yml — the push stderr log is written to $RUNNER_TEMP instead of the repo working tree, and the duplicate ::error:: annotation on an exec failure is dropped (the per-command annotation remains).

Deliberately skipped (documented follow-ups)

  • Unify the jscpd config resolution that currently happens in both the shell runner (--config file) and the JS threshold read (resolveConfig). They can diverge for a non-default jscpdConfigPath containing a subdirectory. The deep fix is to resolve jscpd config once in JS and emit a plan (mirroring the dotnet format path) — a structural change that's risky to land without a live end-to-end run, so it's left as a follow-up.
  • The github-script pathToFileURL/import() boilerplate repeated across 3 steps — explicit per-step imports are clearer than a dispatcher indirection.

https://claude.ai/code/session_01JxEe85CyGm5rCeoLFdUZed

Quality cleanups from a 4-angle review of the composite-action diff:

- report-common.mjs: add buildReportContext(context); both report wrappers
  (format-report, jscpd-report) now call it instead of hand-building the identical
  owner/repo/sha/cwd/runId/commit object.
- jscpd-report.mjs: buildJscpdMessage takes the pre-computed `header` (like
  generateReport) instead of recomputing getReportHeader internally; wrapper passes it.
- format-args.mjs: collapse buildDefaultOptions' 4 near-identical blocks to a base +
  spread (only the two real overrides remain); simplify checkIsDryRun's granular check
  via a `dry()` helper; drop the unused `config` field from planFormat's return; make
  internal-only buildArgs/FormatType module-private.
- comment.mjs: run the independent listComments + getAuthenticated calls with
  Promise.all (getAuthenticated still degrades to undefined on 403).
- action.yml: write the push stderr log to $RUNNER_TEMP instead of the repo tree, and
  drop the duplicate ::error:: annotation on exec failure (per-command one remains).

Skipped (documented as follow-ups): unifying the jscpd config resolution that happens
in both the shell runner and the JS threshold read (structural; risky without an e2e
run), and the github-script import boilerplate (explicit per-step is clearer).

biome check + 33 node:test green; wrappers smoke-tested; bash -n + YAML clean.

Claude-Session: https://claude.ai/code/session_01JxEe85CyGm5rCeoLFdUZed
@maxisam maxisam merged commit 0b5debe into main Jun 27, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant